package com.yb.guigu.pick.core.util;

import java.util.Random;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/6/12 14:48
 * FileName: RandomUtil
 * Description:
 */
public class RandomUtil {

    private static final String BASIC = "123456789qwertyuiopasdfghjklzxcvbnm";


    private static final String NUMBER="1234567890";
    public static String generator(int length){
        if(length<=0)return "";
        char[] basicArray = BASIC.toCharArray();
        Random random = new Random();
        char[] result = new char[length];
        for (int i = 0; i < result.length; i++) {
            int index = random.nextInt(100) % (basicArray.length);
            result[i] = basicArray[index];
        }
        return new String(result);
    }

    public static String generateNumber(int length){
        if(length<=0)return "";
        char[] basicArray = NUMBER.toCharArray();
        Random random = new Random();
        char[] result = new char[length];
        for (int i = 0; i < result.length; i++) {
            int index = random.nextInt(100) % (basicArray.length);
            result[i] = basicArray[index];
        }
        return new String(result);
    }
}
